<include file="public/layout"/>
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>

<style type="text/css">
    html, body {overflow: visible;}
</style>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer"
     style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>参数管理 -- 联系我们</h3>
                <h5></h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" action="{:U('Home/saveAbout')}" id="add_post" method="post">
        <div class="ncap-form-default">

            <!--<div class="fixed-bar1">
                <div class="item-title">
                    <div class="subject">
                        <h3>联系我们信息</h3>
                        <h5>首页联系我们信息设置</h5>
                    </div>
                    <ul class="tab-base nc-row"></ul>
                </div>
            </div>-->

            <dl class="row">
                <dt class="tit">
                    <label for="site_member">标题</label>
                </dt>
                <dd class="opt">
                    <input id="site_member" name="site_member" value="{$info.site_member}" class="input-txt" type="text" />
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="site_tel">电话</label>
                </dt>
                <dd class="opt">
                    <input id="site_tel" name="site_tel" value="{$info.site_tel}" class="input-txt" type="text" />
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="site_email">Email</label>
                </dt>
                <dd class="opt">
                    <input id="site_email" name="site_email" value="{$info.site_email}" class="input-txt" type="text" />
                </dd>
            </dl>
            <div class="link-box">
                <dl class="row">
                    <dt class="tit">
                        <label>客服qq</label>
                    </dt>
                    <dd class="opt" style="position:relative;">
                        <input name="link_name[]"  class="input-txt" type="text" style="width: 100px !important;" placeholder="名称"/>
                        <input name="link_url[]"  class="input-txt" type="text" placeholder="qq"/>
                        <label>
                            <img class="add-link-btn" src="__PUBLIC__/images/plus.png" alt="" style="width: 27px;position: absolute;top:1px;cursor: pointer">
                        </label>
                        <p class="notic">(名称不得重复,否则将覆盖)</p>
                    </dd>
                </dl>
                <if condition="$info['site_server_tel']">
                    <foreach name="$info['site_server_tel']" item="v" key="k">
                        <dl class="row row-now-{$k}">
                            <dt class="tit">
                                <label></label>
                            </dt>
                            <dd class="opt" style="position:relative;">
                                <input name="link_name[]"  class="input-txt" value="{$v.name}" type="text" style="width: 100px !important;" placeholder="名称"/>
                                <input name="link_url[]"  class="input-txt" value="{$v.url}" type="text" placeholder="qq"/>
                                <label>
                                    <img class="reduce-btn" data-now="{$k}" src="__PUBLIC__/images/reduce.png" alt="" style="width: 27px;position: absolute;top:1px;cursor: pointer">
                                </label>
                            </dd>
                        </dl>
                    </foreach>
                </if>
            </div>

            <script>
                var index = 1;
                var lind_index = 1;

                $(function () {

                    //友情链接
                    $('.link-box .reduce-btn').click(function () {

                        var now = $(this).attr('data-now');

                        $('.link-box .row-now-'+now).remove();
                    })

                    //友情链接
                    $('.link-box .add-link-btn').click(function () {


                        var html = '<dl class="row row'+lind_index+'">' +
                            '       <dt class="tit">' +
                            '       <label for="address"></label>' +
                            '       </dt>' +
                            '       <dd class="opt" style="position:relative;">' +
                            '       <input name="link_name[]"  class="input-txt" type="text" style="width: 100px !important;" placeholder="名称"/>' +
                            '       <input name="link_url[]"  class="input-txt" type="text" placeholder="qq"/>' +
                            '       <label>' +
                            '       <img class="reduce-link-btn" data-index="'+lind_index+'" src="__PUBLIC__/images/reduce.png" alt="" style="cursor:pointer;width: 27px;position: absolute;top:1px;">' +
                            '       </label>' +
                            '       </dd>' +
                            '       </dl>';

                        $('.link-box').append(html);

                        lind_index ++;

                        $('.reduce-link-btn').click(function () {

                            var data_index = $(this).attr('data-index');
                            $('.link-box .row'+data_index).remove();

                        })

                    })
                })
            </script>
            <dl class="row">
                <dt class="tit">
                    <label for="site_tips">提示</label>
                </dt>
                <dd class="opt">
                    <textarea name="site_tips" id="site_tips" class="form-control" style="width: 50%;height: 100px;">{$info.site_tips}</textarea>
                </dd>
            </dl>

            <div class="bot">
                <input type="hidden" name="is_ajax" value="1">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

    $(function () {
        $('#publish_time').layDate();
    });

    $(document).on("click", '#submitBtn', function () {
        verifyForm();
    });

    function verifyForm() {
        $('span.err').hide();
        $.ajax({
            type: "POST",
            url: "{:U('Home/saveAbout')}",
            data: $('#add_post').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
                if (data.status === 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.href = "{:U('Admin/Home/saveAbout')}";
                    });
                } else if (data.status === 0) {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }
            }
        });
    }
</script>
</body>
</html>